package com.dgut.crm.system.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name="department")
public class Department 
{
	private Long id;
	private String name;
	private String nature; //性质
	private String remark; //备注 
	
	private List<Number> numbers = new ArrayList<Number>();
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	@Column(length=20,unique=true,nullable=false)
	public String getName() {
		return name;
	}

	@Column(length=50,nullable=true)
	public String getNature() {
		return nature;
	}

	@Lob
	public String getRemark() {
		return remark;
	}
	
	//由多方维护关系
	@JsonIgnore
	@OneToMany(cascade=CascadeType.ALL,mappedBy="department",fetch=FetchType.LAZY)
	public List<Number> getNumbers() {
		return numbers;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setNature(String nature) {
		this.nature = nature;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public void setNumbers(List<Number> numbers) {
		this.numbers = numbers;
	}

	public Department() {
	}
	public Department(Long id, String name, String nature, String remark) {
		super();
		this.id = id;
		this.name = name;
		this.nature = nature;
		this.remark = remark;
	}

	@Override
	public String toString() {
		return "Department [id=" + id + ", name=" + name + ", nature=" + nature + ", remark=" + remark + "]";
	}
}
